<template>
	<view class="crm">
		<!-- <u-sticky> -->
			<view class="tops1">
				<view class="searchBox">
					<view class="search">
						<view class="inp">
							<u-search @change="changeInpFn" :clearabled="true" @clear="search" @search="search" bg-color="#fff" :show-action="false" height="60" search-icon=""
								placeholder-color="rgba(15, 20, 23, 0.3)" placeholder="请输入手机号或用户ID" v-model="keyword">
							</u-search>
						</view>
						<view class="btns" @click="search">
							搜索
						</view>
					</view>

				</view>
				<view class="selectOptions">
					<u-tabs
					bar-width="96"
					bar-height="4"
					inactive-color='rgba(15, 20, 23, 0.7)'
					active-color="rgba(15, 20, 23, 1)"
					font-size="28"
					 :bar-style="barStyle" :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
				</view>
				<view class="borderGap">
					
				</view>
			</view>
		<!-- </u-sticky> -->
		<view v-if="list1.length" class="list" :style="{'padding-top': paddingTop}">
			<view class="item" v-for="(item,index) in list1" @click="godetail(item)">
			<view class="sameStyle">
				<view class="left">
					<text>{{item.recordCode}}</text>
					<text v-if="item.flowStatus=='APPLIED'" class="status doing">
						审核中
					</text>
					<text v-else-if="item.flowStatus=='REJECTED'" class="status">
						已拒绝
					</text>
					<text v-else class="status ok">
						已通过
					</text>
				</view>
				<view class="right">
					{{item.authTypeName}}
				</view>
				
			</view>
			<view class="u-m-t-10 sameStyle bot">
				<view class="left">
					<text>{{item.genTime}}</text>
				</view>
				<view class="right">
					{{item.mobile}}
				</view>
				
			</view>
			
			</view>
			<uni-load-more :status="status"></uni-load-more>
		</view>
		<view v-else class="empty" style="padding-top: 150px;">
			<view v-if="!list1.length && senDate" class="emptyAddress-box">
				<u-empty text="暂无内容" mode="news"></u-empty>
			</view>
		</view>


	</view>
</template>

<script>
	import {
		shareMixins
	} from "../../common/share.js"
	import Base64 from 'base-64';
	import CryptoJS from '../../node_modules/crypto-js/crypto-js.js'

	let publicKey =
		`MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDEPqHavyfprY52X/RFbuTq8qz9rLnbGPYMTgKZNL2dAp+1lj0zuwJyPf35/Icu1iO0iFps8lJ089oNCJNh1FXKs+sje0bXQIxFr0axmKtaeWzErD/9Iv5hvq01s1sPjZ3x4fvCvStue2rbXlWbm+PmtVssjsBbMajkbgghmM2RwQIDAQAB`

	export default {

		mixins: [shareMixins],

		data() {
			return {
				flowStatusList:['APPLIED','REJECTED','CHECKED'],
				barStyle:{
					'width': '96rpx',
					'height': '4rpx',
					'background': 'linear-gradient( 211deg, #EF8548 0%, #DE4543 100%)'
				},
				list: [{
					name: '审核中'
				}, {
					name: '已拒绝'
				}, {
					name: '已开通'
				}],
				current: 0,
				claName: '',
				checkAll: false,
				shareMixins: {
					path: '/subPack/crm/index'
					// '/pages/index/index?id=1' // 分享的页面路径
				},

				curId: '',
				curPhone: '',
				transferPhone: '',
				transferToAppMask: false,
				total: null, //总共多少条数据
				formData: {
					pageSize: 10, //每页10条数据
					page: 1, //第几页
					topic: "",
				},
				status: "more",
				senDate: false,
				list1: [],

				keyword: '',
				gender: "",
				isVip: "",
				cardTypeIds: [],
				paddingTop:""

			}
		},
onReady() {
			uni.createSelectorQuery().select('.tops1').boundingClientRect((rect) => {
				console.log(rect.height, 66666);
				this.paddingTop = rect.height + 'px'
			}).exec()
		},
		onLoad() {

			this.getlist()
		
		},
		onPullDownRefresh() {
			
			// uni.showLoading({
			// 	title: '刷新中...',
			// 	mask: true
			// })
			this.formData.page = 1;
			this.getlist('fresh');
		},
		onReachBottom() {
			let allTotal = this.formData.page * this.formData.pageSize;
			if (allTotal < this.total) {
				//当前条数小于总条数 则增加请求页数
				this.status = "loading"; //加载中状态
				this.formData.page++;
				this.getlist();
			} else {
				this.status = "noMore"; //加载完状态
				console.log("已加载全部数据");
			}
		},
		methods: {
			changeInpFn(e){
				
				if(e==''){
					this.formData.page = 1;
					this.getlist('fresh');
				}
				
			},
			change(index) {
				this.current = index;
				// this.formData.page = 1
				// this.list1 = []
				// this.getlist();
				
				this.formData.page = 1;
				this.getlist('fresh');
				
			},
			GetcardTypeCodeImg(item){
				if(item.afterCardTypeCode=='101' ){
					return ''
				}else if(item.afterCardTypeCode=='102' ||item.afterCardTypeCode=='103' ){
					return 'https://oss.6mate.cn/mini/basevip.png'
				}else if(item.afterCardTypeCode=='104' ||item.afterCardTypeCode=='105' ){
					return 'https://oss.6mate.cn/mini/huangjinvip.png'
				}else if(item.afterCardTypeCode=='106' ||item.afterCardTypeCode=='107' ){
					return 'https://oss.6mate.cn/mini/baijinvip.png'
				}else if(item.afterCardTypeCode=='108' ||item.afterCardTypeCode=='109' ){
					return 'https://oss.6mate.cn/mini/zuanshivip.png'
				}
			},
		

			search() {
				// this.formData.page = 1
				// this.list1 = []
				// this.getlist();
				
				this.formData.page = 1;
				this.getlist('fresh');


			},
			getlist(type) {
				this.senDate = false;
				let query = {
					pageIndex: this.formData.page,
					pageSize: this.formData.pageSize,
					flowStatus: this.flowStatusList[this.current],
					keyWord:this.keyword
				}
		
				this.$u.api
					.authRecord(query)
					.then((res) => {
						if(type=='fresh'){
							this.list1 = [];
						}
						this.senDate = true;
						if (res.code == 'ok') {
							this.total = res.data.entityCount;
							const newlist = res.data.entities;
							this.list1.push(...newlist);
							if (this.list1.length < this.formData.pageSize) {
								this.status = "noMore"; //加载完状态
							}
						} else {}
						uni.stopPullDownRefresh()
						uni.hideLoading();
					});
			},

			godetail(e) {
				uni.navigateTo({
					url: "/subPack/authentication/detail?id=" + e.id
				})
			}
		}
	}
</script>

<style>
	page {
		background: #fff;
	}
</style>
<style scoped lang="scss">
	.crm {
		padding: 0 0 24rpx;
		.tops1 {
			background: #FFFFFF;
			padding: 24rpx 0 0;
			position: fixed;
			left: 0;
			top: 0;
			right: 0;
			z-index: 9;
		}
		.list {
			padding: 0 40rpx;
			.item {
				padding: 26rpx 0;
				border-bottom: 2rpx solid  #F6F6F6;
				
				// margin-bottom:24rpx;
				// padding: 0 24rpx;
				// background: #FFFFFF;
				// border-radius: 16rpx 16rpx 16rpx 16rpx;
				.sameStyle{
					display: flex;
					align-items: center;
					justify-content: space-between;
					.left{
						font-family: Alibaba PuHuiTi, Alibaba PuHuiTi;
						font-weight: 500;
						font-size: 28rpx;
						color: #0F1417;
						line-height: 40rpx;
						.status{
							padding-left: 16rpx;
							font-family: Alibaba PuHuiTi, Alibaba PuHuiTi;
							font-weight: 500;
							font-size: 28rpx;
							color: #6F7274;
							line-height: 33rpx;
							&.doing{
								color: #FFA340 !important;
							}
							&.ok{
								color: #1BAB6B !important;
							}
						}
					}
					
				}
				.bot{
					.left,.right{
						font-family: Alibaba PuHuiTi, Alibaba PuHuiTi;
						font-weight: 400;
						font-size: 24rpx;
						color:rgba(15, 20, 23, 0.4) !important;
						line-height: 28rpx;
					}
				}
				
			}
		}

		.borderGap {
			// margin-bottom: 8rpx;
			border-bottom: 2rpx solid #E7E7E7;
			margin-top: -4rpx;
			
		}

		.searchBox {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin: 0 32rpx 0;
		}

		.search {
			flex: 1;

			height: 64rpx;
			background: #FFFFFF;
			border-radius: 152rpx 152rpx 152rpx 152rpx;
			border: 2rpx solid #FA4A53;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.inp {
				flex: 1;
			}

			.btns {
				display: flex;
				align-items: center;
				justify-content: center;
				font-family: Alibaba PuHuiTi, Alibaba PuHuiTi;
				font-weight: 400;
				font-size: 24rpx;
				color: #FFFFFF;
				line-height: 40rpx;
				margin: 4rpx;
				width: 128rpx;
				height: 56rpx;
				background: #FA4A53;
				border-radius: 152rpx 152rpx 152rpx 152rpx;
			}
		}

	}
</style>
